<?php


/**
 * 银行卡资料
 * @author yw
 */

class Card_model extends BS_Model
{
	public function __construct()
	{
		parent::__construct();
	}

	public function getBankList()
	{
		$this->db->select('DISTINCT(banktypename),bankcode');
		$this->db->from('banklist');
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getProvince($bankcode)
	{
		$this->db->select('DISTINCT(docname)');
		$this->db->from('banklist');
		$this->db->where('bankcode',$bankcode);
		$query = $this->db->get();
		return $query->result_array();
	}

	public function getCity($bankcode,$bankname)
	{
		$this->db->select('DISTINCT(city)');
		$this->db->from('banklist');
		$where = array('bankcode'=>$bankcode,'docname'=>$bankname);
		$this->db->where($where);
		$query = $this->db->get();
		if($query->num_rows()>0)
		{
			return $query->result_array();
		}

		return array();	
	}

	public function getSubbranch($bankcode,$bankname,$cityname)
	{
		$this->db->select('id,bankname');
		$this->db->from('banklist');
		$where = array('bankcode'=>$bankcode,'docname'=>$bankname,'city'=>$cityname);
		$this->db->where($where);
		$query = $this->db->get();
		if($query->num_rows()>0)
		{
			return $query->result_array();
		}
		return array();
	}

	public function getBankNameByBankcode($bankcode)
	{
		$query = $this->db->select('banktypename')->from('banklist')->where('bankcode',$bankcode)->limit(1)->get();
		if($query->num_rows()>0)
			return $query->row_array();

		return array();
	}
}